package com.cy.pj;

import com.cy.pj.notice.pojo插件lombok注解代替set和get方法.SysNotice;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class Controller层JSONTests底层转化为json字符串的过程源码 {

@Test
public void testJson() throws JsonProcessingException {
    SysNotice notice=new SysNotice();
   notice.setId(100L);
    notice.setTitle("Study");
   notice.setContent("Json...");
   notice.setRemark("Json remark...");
   notice.setStatus("0");
   notice.setType("1");
//基于jackson中ObjectMapper类的实例将pojo转换为json格式字符串
   String jsonString=new ObjectMapper().writeValueAsString(notice);
    System.out.println(jsonString);

}
}
